package com.lanjiu.lib.utils.th;

/**
 * @description: Thread 工具类
 * @author: Panwei
 * @date: 2019/10/28 19:35
 */
public class Threader {
    private Threader() {
    }

    public static void sleep(int millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            System.err.println(e.getLocalizedMessage());
        }
    }

    public static void sleep(int millis, OnSleepExceptionListener listener) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            listener.onSleepException(e);
        }
    }

    public static void run(Runnable target) {
        new Thread(target).start();
    }

    public interface OnSleepExceptionListener {
        void onSleepException(InterruptedException e);
    }
}
